package com.sunny.cloudconfigclient.loader;

import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @author Sunny
 * @date 2020/7/16
 */
public class CustomerPropertySource extends EnumerablePropertySource {

    public CustomerPropertySource(String name, Object source) {
        super(name, source);
    }


    @Override
    public String[] getPropertyNames() {
        return StringUtils.toStringArray(((Map)this.source).keySet());
    }

    /**
     * 根据key获取配置值
     *
     * @param name
     * @author Sunny
     * @date 2020/7/16
     */
    @Override
    public Object getProperty(String name) {
        return ((Map)this.source).get(name);
    }
}
